package com.zzj.controller;

import com.zzj.annotation.LogAnnotation;
import com.zzj.annotation.RateLimitAnnotation;
import com.zzj.base.Result;
import com.zzj.service.RedisService;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisController {

    @Resource
    private RedisService redisService;


    @RateLimitAnnotation()
    @LogAnnotation(name = "获取公告", description = "获取公告")
    @Transactional
    @PostMapping("getAnnouncement")
    public Result getAnnouncement() {
        String announcement = redisService.getAnnouncement();
        return Result.success("操作成功", announcement);
    }

    @LogAnnotation(name = "设置公告", description = "设置公告")
    @Transactional
    @PostMapping("setAnnouncement")
    public Result setAnnouncement(@RequestParam("text") String text) {
        return redisService.setAnnouncement(text);
    }


}
